package com.qnzw.zjmy.home.fragment;

import android.app.AlertDialog;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.volley.Request;
import com.anythink.nativead.api.ATNativeAdView;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.ruffian.library.widget.RTextView;
import com.umeng.commonsdk.UMConfigure;
import com.qnzw.zjmy.BuildConfig;
import com.qnzw.zjmy.R;
import com.qnzw.zjmy.ad.MediationFeedAd;
import com.qnzw.zjmy.ad.MediationTablePlaqueAd;
import com.qnzw.zjmy.ad.kaku.banner.TaKuBannerAdOBJ;
import com.qnzw.zjmy.ad.kaku.interstitia.TaKuInterstitialAdTwo;
import com.qnzw.zjmy.config.UrlAddressConfig;
import com.qnzw.zjmy.config.UrlConfig;
import com.qnzw.zjmy.home.ui.activity.CollectActivity;
import com.qnzw.zjmy.home.ui.activity.DeleteUserActivity;
import com.qnzw.zjmy.home.ui.activity.InviteRecordActivity;
import com.qnzw.zjmy.home.ui.activity.InviteUserActivity;
import com.qnzw.zjmy.home.ui.activity.LikeGoodsActivity;
import com.qnzw.zjmy.home.ui.activity.RewardRecordActivity;
import com.qnzw.zjmy.home.ui.activity.SetUpActivity;
import com.qnzw.zjmy.home.ui.activity.SignInActivity;
import com.qnzw.zjmy.home.ui.enums.MoneyTypeEnum;
import com.qnzw.zjmy.home.ui.enums.RedisEnum;
import com.qnzw.zjmy.home.ui.model.InviteCodeVo;
import com.qnzw.zjmy.home.ui.model.User;
import com.qnzw.zjmy.home.ui.model.statistics.DayAdReward;
import com.qnzw.zjmy.home.ui.model.vo.BaseVo;
import com.qnzw.zjmy.home.ui.model.vo.UserDailyActivityVo;
import com.qnzw.zjmy.home.ui.model.vo.UsersVo;
import com.qnzw.zjmy.home.ui.widget.CenterInviteCodeDialog;
import com.qnzw.zjmy.service.RiskService;
import com.qnzw.zjmy.utils.StringSplit;
import com.qnzw.zjmy.utils.VersionUtils;
import com.qnzw.zjmy.utils.risk.DeviceUtils;
import com.qnzw.zjmy.utils.risk.RiskUtils;
import com.qnzw.zjmy.utils.risk.VirtualApkCheckUtil;
import com.qnzw.zjmy.volley.BaseFragment;
import com.qnzw.zjmy.volley.state.HUCState;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;


public class MyFragmentStyle2 extends BaseFragment {
    private View view;
    private TextView tvMoneyRedPacket, tvMoneyGoldCoin, tvNickname, tvCode, tvCount, tv_parent_id;
    private RTextView tv_write_parent_id;
    //邀请码弹窗
    private CenterInviteCodeDialog mCenterQRCodeDialog;
    private String usParentId;
    private VirtualApkCheckUtil virtualApkCheckUtil;
    private RiskUtils riskUtils;
    private DeviceUtils deviceUtils;
    //update nickname
    private AlertDialog alertDialog;
    private EditText etName;
    private boolean isVisibleToUser = false;
    private MediationTablePlaqueAd mediationTablePlaqueAd;
    private LinearLayout ll_channel_type;
    private TextView channel_package;

    public MyFragmentStyle2() {
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        this.isVisibleToUser = isVisibleToUser;
        if (isVisibleToUser) {
            initAd();
        }
        super.setUserVisibleHint(isVisibleToUser);
    }


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (ObjectUtil.isNotNull(view)) {
            return view;
        }
        view = inflater.inflate(R.layout.view_page_my_style2, container, false);
        super.onCreateView(inflater, container, savedInstanceState);
        return view;
    }

    @Override
    public void onResume() {
        loadDayAdReward();
//        ImmersionBar.with(this).titleBar(view.findViewById(R.id.layout_top)).statusBarDarkFont(true).init();
        super.onResume();
    }

    @Override
    public void initView() {
        super.initView();
        virtualApkCheckUtil = VirtualApkCheckUtil.getSingleInstance();
        deviceUtils = DeviceUtils.getInstance();
        riskUtils = RiskUtils.getInstance();

        tvCount = view.findViewById(R.id.tv_count);
        tvMoneyGoldCoin = view.findViewById(R.id.tv_moneyGoldCoin);
        tvMoneyRedPacket = view.findViewById(R.id.tv_moneyRedPacket);
        tvNickname = view.findViewById(R.id.tv_nickname);
        tvCode = view.findViewById(R.id.tv_code);
        tv_parent_id = view.findViewById(R.id.tv_parent_id);
        tv_write_parent_id = view.findViewById(R.id.tv_write_parent_id);
        if (isVisibleToUser) {
            initAd();
        }
        tvNickname.setText(getSharedPreferences("nickname"));
        tvCode.setText("ID:" + getSharedPreferences("id"));


        ll_channel_type = view.findViewById(R.id.ll_channel_type);
        String RISK_SHARE_OPEN_APP = getSharedPreferences(RedisEnum.RISK_SHARE_OPEN_APP.getKey());

        if (RISK_SHARE_OPEN_APP.equals("1")) {
            ll_channel_type.setVisibility(View.VISIBLE);

        } else {
            ll_channel_type.setVisibility(View.GONE);

        }


        channel_package = view.findViewById(R.id.channel_package);
        channel_package.setText("渠道ID:" + BuildConfig.CHANNEL_PACKAGE);
    }

    @Override
    public void initClick() {
        super.initClick();
        view.findViewById(R.id.ll_setup).setOnClickListener(this);
        view.findViewById(R.id.ll_feedback).setOnClickListener(this);
        view.findViewById(R.id.tv_nickname).setOnClickListener(this);
//        view.findViewById(R.id.layout_sign).setOnClickListener(this);
        view.findViewById(R.id.layout_sign).setOnClickListener(this);
        view.findViewById(R.id.ll_invite_record).setOnClickListener(this);
        view.findViewById(R.id.tv_moneyRedPacket).setOnClickListener(this);
        view.findViewById(R.id.ll_delete).setOnClickListener(this);
        view.findViewById(R.id.layout_like).setOnClickListener(this);

        view.findViewById(R.id.ll_invite).setOnClickListener(this);
        view.findViewById(R.id.ll_recommend).setOnClickListener(this);
        view.findViewById(R.id.tv_reward_record).setOnClickListener(this);
        view.findViewById(R.id.tv_h_bao).setOnClickListener(this);

        setDate();
    }

    private void setDate() {
        view.findViewById(R.id.tv_write_parent_id).setOnClickListener(this);
        usParentId = getSharedPreferences("usParentId");
        if (usParentId == null || "".equals(usParentId) || usParentId.equals("null")) {
            tv_write_parent_id.setOnClickListener(this);
            mCenterQRCodeDialog = (CenterInviteCodeDialog) new XPopup.Builder(getContext())
                    .moveUpToKeyboard(false)
                    .dismissOnTouchOutside(false)
                    .asCustom(new CenterInviteCodeDialog(getContext()));
            tv_write_parent_id.setVisibility(View.VISIBLE);
        } else {
            tv_parent_id.setText("上级ID:" + usParentId);
            tv_write_parent_id.setVisibility(View.GONE);
        }
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {

            case R.id.ll_invite:
                sendIntent(this.getActivity(), InviteUserActivity.class);
                break;
            case R.id.ll_recommend:
                sendIntent(this.getActivity(), InviteRecordActivity.class);
                break;
            case R.id.tv_write_parent_id:
                mCenterQRCodeDialog.setConfirmClickListener(new CenterInviteCodeDialog.ConfirmClickListener() {
                    @Override
                    public void onConfirmClick(String inviteCode) {
                        InviteCodeVo inviteCodeVo = new InviteCodeVo();
                        inviteCodeVo.setCode(inviteCode);
                        inviteCodeVo.setToken(getSharedPreferencesToken("token"));
                        hucRequestInterfase.executeStr(MyFragmentStyle2.this, User.class, HUCState.HUC_REQEUST_CODE_5, Request.Method.POST, UrlConfig.URL_USER_BIND_INVITER, hucParameInterfase.getRequestParameter(inviteCodeVo), true);
                    }
                });
                mCenterQRCodeDialog.show();
                break;
            case R.id.ll_delete:
                sendIntent(this.getActivity(), DeleteUserActivity.class);
                break;
            case R.id.ll_setup:
                sendIntent(this.getActivity(), SetUpActivity.class);
                break;
            case R.id.ll_feedback:
                sendIntent(this.getActivity(), CollectActivity.class);
                break;
            case R.id.layout_like:
                sendIntent(this.getActivity(), LikeGoodsActivity.class);
                break;
            case R.id.tv_reward_record:
                sendIntent(this.getActivity(), RewardRecordActivity.class, String.valueOf(HUCState.HUC_REQEUST_CODE_1));
                break;
            case R.id.tv_h_bao:
                sendIntent(this.getActivity(), RewardRecordActivity.class, String.valueOf(HUCState.HUC_REQEUST_CODE_2));
                break;
            case R.id.ll_invite_record:
            case R.id.tv_moneyRedPacket:
                sendIntent(this.getActivity(), InviteRecordActivity.class);
                break;
            case R.id.layout_sign:
                sendIntent(this.getActivity(), SignInActivity.class, HUCState.HUC_REQEUST_CODE_1);
                break;
            case R.id.tv_nickname:
                showUpdateNickname();
                break;
            default:
                break;
        }
    }

    @Override
    public void onSuccessfulStrType(int inputType, Object response) {
        super.onSuccessfulStrType(inputType, response);
        switch (inputType) {
            case HUCState.HUC_REQEUST_CODE_1:
                if (!(response instanceof DayAdReward)) {
                    showToast(response.toString());
                    return;
                }
                DayAdReward dayAdReward = (DayAdReward) response;
                tvMoneyRedPacket.setText(dayAdReward.getMoney_red_envelope());
                tvMoneyGoldCoin.setText(dayAdReward.getMoney_gold_coins());
                String dayNumber = getSharedPreferences(RedisEnum.DAILY_TASK_FREQUENCY.getKey());
                tvCount.setText(dayAdReward.getDay_reward_count() + "/" + dayNumber);
                setSharedPreferences("day_reward_count", dayAdReward.getDay_reward_count());
                setSharedPreferences(MoneyTypeEnum.MONEY_COMMISSION_GOLD_COINS.getKey(), dayAdReward.getMoney_commission_gold_coins());
                setSharedPreferences(MoneyTypeEnum.MONEY_COMMISSION_RED_ENVELOPE.getKey(), dayAdReward.getMoney_commission_red_envelope());
                setSharedPreferences(MoneyTypeEnum.MONEY_EXTENSION_RED_ENVELOPE.getKey(), dayAdReward.getMoney_extension_red_envelope());
                setSharedPreferences(MoneyTypeEnum.MONEY_EXTENSION_RED_ENVELOPE.getKey(), dayAdReward.getMoney_extension_red_envelope());
                ProgressBar progressBar = view.findViewById(R.id.progress_bar);
                try {
                    double rewardCountTask = Double.valueOf(dayAdReward.getDay_reward_count());
                    double dayNumberAll = Double.valueOf(dayNumber);
                    if (rewardCountTask > 0) {
                        int progressValue = (int) (rewardCountTask / dayNumberAll * 100);
                        progressBar.setProgress(progressValue);
                    } else {
                        progressBar.setProgress(0);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            case HUCState.HUC_REQEUST_CODE_2:
                if (response instanceof String) {
                    String msg = (String) response;
                    showToast(msg);
                    alertDialog.dismiss();
                    setSharedPreferences("nickname", etName.getText().toString());
                    tvNickname.setText(etName.getText().toString());
                }
                break;
            case HUCState.HUC_REQEUST_CODE_4:
                loadDismiss();
                if (!(response instanceof User)) {
                    showToast(response.toString());
                    return;
                }
                User users = (User) response;
                setSharedPreferences("id", users.getId());
                setSharedPreferences("deviceId", users.getOpenid() + users.getDeviceId());
                setSharedPreferences("loginTime", users.getLoginTime());
                setSharedPreferences("signInNumber", users.getSignInNumber());
                setSharedPreferences("signIdDayNumber", users.getSignIdDayNumber());
                if (!users.getAfbName().equals("null") || users.getAfbName().isEmpty()) {
                    setSharedPreferences("afbName", users.getAfbName());
                    setSharedPreferences("afbPhone", users.getAfbPhone());
                }
                setSharedPreferences("code", users.getCode());
                setSharedPreferences("moneyRedPacket", users.getMoneyRedPacket());
                setSharedPreferences("moneyGoldCoin", users.getMoneyGoldCoin());
                setSharedPreferences("nickname", users.getNickname());
                setSharedPreferences("usParentId", users.getUsParentId());
                String index = getSharedPreferences("currentSubject");
                setSharedPreferences("currentSubject", StrUtil.isNotEmpty(index) ? index : "0");
                String answerCount = getSharedPreferences("answerCount");
                setSharedPreferences("answerCount", StrUtil.isNotEmpty(answerCount) ? answerCount : "0");
                setSharedPreferences(RedisEnum.RISK_ADVERTISING_COINS.getKey(), users.getRisk_advertising_coins());
                setSharedPreferences(RedisEnum.RISK_ADVERTISING_COINS_THAN_EQUAL.getKey(), users.getRisk_advertising_coins_than_equal());
                setSharedPreferences(RedisEnum.RISK_ADVERTISING_COINS_THAN_EQUAL_TWO.getKey(), users.getRisk_advertising_coins_than_equal_two());
                setSharedPreferences(RedisEnum.RISK_WHITE_LIST.getKey(), users.getRisk_white_list());
                setDate();
                Toast.makeText(getContext(), "绑定成功", Toast.LENGTH_SHORT).show();
                break;
            case HUCState.HUC_REQEUST_CODE_5:
                load();
                break;
        }
        loadDismiss();
    }

    private void load() {
        UserDailyActivityVo baseVo = new UserDailyActivityVo();
        //双开2.0版本
        Intent serviceIntent = new Intent(getContext(), RiskService.class);
        serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getContext().startService(serviceIntent);
        //是否分身
        boolean flag = virtualApkCheckUtil.checkByCreateLocalServerSocket(deviceUtils.getPackageName(getContext()));
        baseVo.setUdaSeparation(String.valueOf(flag ? 1 : 2));
        //是否模拟器
        flag = riskUtils.detectEmulator(getContext());
        baseVo.setUdaSimulator(String.valueOf(flag ? 1 : 2));
        //是否开启调试模式
        flag = deviceUtils.isDeveloperModeEnabled(getContext());
        baseVo.setUdaDebugMode(String.valueOf(flag ? 1 : 2));
        //是否USB调试模式
        flag = deviceUtils.isAdbEnabled(getContext());
        baseVo.setUdaUsbMode(String.valueOf(flag ? 1 : 2));
        //是否root
        flag = deviceUtils.isDeviceRooted(getContext());
        baseVo.setUdaRoot(String.valueOf(flag ? 1 : 2));
        //是否开启无障碍模式
        flag = deviceUtils.isAccessibilityServiceEnabled(getContext());
        baseVo.setUdaAccessibility(String.valueOf(flag ? 1 : 2));
        //是否开启VPN代理模式
        flag = deviceUtils.isWifiProxy();
        baseVo.setUdaVpnProxy(String.valueOf(flag ? 1 : 2));

        if (UrlAddressConfig.CHANNEL_TYPE != 1) {
            baseVo.setUdaSeparation(String.valueOf(2));
            //是否模拟器
            baseVo.setUdaSimulator(String.valueOf(2));
            //是否开启调试模式
            baseVo.setUdaDebugMode(String.valueOf(2));
            //是否USB调试模式
            baseVo.setUdaUsbMode(String.valueOf(2));
            //是否root
            baseVo.setUdaRoot(String.valueOf(2));
            //是否开启无障碍模式
            baseVo.setUdaAccessibility(String.valueOf(2));
            //是否开启VPN代理模式
            baseVo.setUdaVpnProxy(String.valueOf(2));
        }

        //运营环境当前电池
        baseVo.setUdaBattery(String.valueOf(riskUtils.checkBatteryManager(getContext())));
        //包名
        baseVo.setUdaPackage(deviceUtils.getPackageName(getContext()));

        //APP名称
        baseVo.setUdaAppName(deviceUtils.getAppName(getContext()));
        //版本号
        baseVo.setUdaVersionCode(VersionUtils.getAppVersionName(getContext()));
        //SIM状态
        baseVo.setUdaSimStatus(String.valueOf(deviceUtils.getSim(getContext())));
        //SIM运营商
        baseVo.setUdaSimOperator(deviceUtils.getNetworkOperatorName(getContext()));
        //悬浮窗状态
        baseVo.setSystemAlertWindow(deviceUtils.getSystemAlertWindow(getContext()));
        //蓝牙状态
        baseVo.setOpenBluetooth(deviceUtils.getOpenBluetooth(getContext()));
        //当前网络
        baseVo.setUdaNetWork(deviceUtils.getNetworkTypeName(getContext()));
        //Android版本号
        baseVo.setUdaAndroid(deviceUtils.getSystemAndroidVersionCode());
        //Mac地址
        baseVo.setUdaMac(deviceUtils.getMacAddr(getContext()));
        //手机品牌
        baseVo.setUdaBrand(deviceUtils.getSystemAndroidMobilePhoneBrand());
        //手机型号&软件版本
        baseVo.setUdaSystemVersionCode(deviceUtils.getSystemAndroidSystemVersionCode());
        //手机应用总数
        List<PackageInfo> packageInfoList = DeviceUtils.getInstance().getAllApps(getContext());
        baseVo.setUdaAllApp(String.valueOf(ObjectUtil.isNotEmpty(packageInfoList) ? packageInfoList.size() : 0));
        List<UserDailyActivityVo> userDailyActivityVoList = new ArrayList<>();
        for (PackageInfo packageInfo : packageInfoList) {
            UserDailyActivityVo userDailyActivityVo = new UserDailyActivityVo();
            String name = deviceUtils.getAppName(getContext(), packageInfo.packageName);
            userDailyActivityVo.setUdaPackage(packageInfo.packageName);
            userDailyActivityVo.setUdaAppName(name);
            userDailyActivityVo.setUdaVersionCode(packageInfo.versionName);
            userDailyActivityVoList.add(userDailyActivityVo);
        }
        // 创建 Gson 实例
        Gson gson = new Gson();
        // 将 User 对象转换为 JSON 字符串
        String jsonString = gson.toJson(userDailyActivityVoList);
        //应用JSON明细
        baseVo.setUdaAllAppDetail(jsonString);
        baseVo.setUmToken(UMConfigure.getUmengZID(getContext()));

        baseVo.setToken(getSharedPreferencesToken("token"));
        hucRequestInterfase.executeStr(this, User.class, HUCState.HUC_REQEUST_CODE_4, Request.Method.POST, UrlConfig.INFO_URL, hucParameInterfase.getRequestParameter(baseVo), true);
    }

    private void loadDayAdReward() {

        //获取网络数据
        loading();
        BaseVo baseVo = new BaseVo();
        baseVo.setToken(getSharedPreferencesToken("token"));
//        baseVo.setOaid(DeviceUtils.getInstance().getOaId(this.getActivity()));
        baseVo.setOaid(getSharedPreferences(RedisEnum.OAID.getKey()));
        hucRequestInterfase.executeStr(this, DayAdReward.class, HUCState.HUC_REQEUST_CODE_1, Request.Method.POST, UrlConfig.URL_TO_DAY_STATISTICS, hucParameInterfase.getRequestParameter(baseVo), true);
    }

    private void showUpdateNickname() {
        //判断提现账号
        AlertDialog.Builder dialog = new AlertDialog.Builder(this.getActivity());
        View root = LayoutInflater.from(this.getActivity()).inflate(R.layout.pop_update_nickname, null);
        dialog.setView(root);
        etName = root.findViewById(R.id.et_nickname);
        etName.setText(getSharedPreferences("nickname"));
        root.findViewById(R.id.tv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = etName.getText().toString();
                if (StrUtil.isEmpty(name)) {
                    showToast("用户名不能为空");
                    return;
                }

                if (StrUtil.length(name) > 6) {
                    showToast("用户名最多六个字符");
                    return;
                }
                UsersVo usersVo = new UsersVo();
                usersVo.setToken(getSharedPreferencesToken("token"));
                usersVo.setNickname(name);
                //请求后台接口
                hucRequestInterfase.executeStr(MyFragmentStyle2.this, null, HUCState.HUC_REQEUST_CODE_2, Request.Method.POST, UrlConfig.URL_UPDATE_NICKNAME, hucParameInterfase.getRequestParameter(usersVo), true);
            }
        });
        root.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.dismiss();
            }
        });
        alertDialog = dialog.create();
        alertDialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
        alertDialog.setCancelable(false);
        alertDialog.show();
    }

    private void initAd() {
        if (ObjectUtil.isNull(view)) {
            return;
        }
        ATNativeAdView adTop = view.findViewById(R.id.ad_top);
        ATNativeAdView adBottom = view.findViewById(R.id.ad_bottom);
        String key = getSharedPreferences(RedisEnum.TA_KU.getKey());
        ATNativeAdView flBanner = view.findViewById(R.id.fl_banner);

        if (RedisEnum.TA_KU.getValue().equals(key)) {
            String code1 = StringSplit.splitOrNull(getSharedPreferences(RedisEnum.BANNER.getKey()), StrUtil.COMMA, 4);
            String code2 = StringSplit.splitOrNull(getSharedPreferences(RedisEnum.BANNER.getKey()), StrUtil.COMMA, 5);
            if (UrlAddressConfig.shouldShowAd()) {
                TaKuInterstitialAdTwo taKuInterstitialAdTwo = TaKuInterstitialAdTwo.getInstance();
                taKuInterstitialAdTwo.setToken(getSharedPreferencesToken("token"));
                taKuInterstitialAdTwo.showAd(this.getActivity());
            }

            TaKuBannerAdOBJ taKuBannerAd1 = new TaKuBannerAdOBJ();
            taKuBannerAd1.setToken(getSharedPreferencesToken("token"));
            taKuBannerAd1.load(getContext(), code1, adTop);

            TaKuBannerAdOBJ taKuBannerAd2 = new TaKuBannerAdOBJ();
            taKuBannerAd2.setToken(getSharedPreferencesToken("token"));
            taKuBannerAd2.load(getContext(), code2, adBottom);


        } else {
            if (UrlAddressConfig.shouldShowAd()) {
                //插屏广告
                MediationTablePlaqueAd mediationTablePlaqueAd = MediationTablePlaqueAd.getInstance();
                mediationTablePlaqueAd.showCacheInterstitialFullAd(this.getActivity(), null);
            }

            String code1 = StringSplit.splitOrNull(getSharedPreferences(RedisEnum.AD_INFORMATION_FLOW.getKey()), StrUtil.COMMA, 4);
            String code2 = StringSplit.splitOrNull(getSharedPreferences(RedisEnum.AD_INFORMATION_FLOW.getKey()), StrUtil.COMMA, 5);
            MediationFeedAd mediationFeedAdTop = new MediationFeedAd();
            mediationFeedAdTop.init(code1);
            mediationFeedAdTop.setFlFeed(adTop);
            mediationFeedAdTop.setActivity(this.getActivity());
            mediationFeedAdTop.showCacheFeedAd();


            MediationFeedAd mediationFeedAdBottom = new MediationFeedAd();
            mediationFeedAdBottom.init(code2);
            mediationFeedAdBottom.setFlFeed(adBottom);
            mediationFeedAdBottom.setActivity(this.getActivity());
            mediationFeedAdBottom.showCacheFeedAd();
        }


    }

}
